package com.mx.web.model;

import java.util.HashSet;
import java.util.Set;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;

public class User {

	@Id
	private String id;
	
	@Indexed(unique=true)
	private String username;
	private String password;
	private boolean enabled;
	private Set<Authority> authorities = new HashSet<Authority>();
	
	public User() {}
	
	public User(String username) {this.username = username;}
	
	public User(String username, String password) {
		this(username, password, "USER");
	}
	
	public User(String username, String password, String authority) {
		this.username = username;
		this.password = password;
		this.enabled = true;
		this.addAuthority(authority);
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	
	public User addAuthority(String authority){
		Authority au =new Authority(authority);
		authorities.add(au);
		return this;
	}

	public Set<Authority> getAuthorities() {
		return authorities;
	}
}
